package uk.ac.lkl.common.associator.event;

import java.util.EventObject;

import uk.ac.lkl.common.associator.Associator;
//import uk.ac.lkl.common.util.*;
import uk.ac.lkl.lpp.dirtyListener;

/**
 * An associator event.
 * 
 * @param the
 *                left element type
 * @param the
 *                annotation type
 * @param the
 *                right element type
 * 
 * @author Darren Pearce
 * @version $Revision: 540 $
 * @version $Date: 2008-01-23 15:59:07 +0000 (Wed, 23 Jan 2008) $
 * 
 */
public class AssociatorEvent<L, A, R> extends EventObject {

    /**
     * The left element affected by this event.
     * 
     */
    private L leftElement;

    /**
     * The annotation affected by this event.
     * 
     */
    private A annotation;

    /**
     * The right element affected by this event.
     * 
     */
    private R rightElement;

    /**
     * Create a new instance for the given associator and association.
     * 
     * @param associator
     *                the associator
     * @param leftElement
     *                the left element
     * @param annotation
     *                the annotation
     * @param rightElement
     *                the right element
     * 
     */
    public AssociatorEvent(Associator<L, A, R> associator, L leftElement,
	    A annotation, R rightElement) {
	super(associator);
	this.leftElement = leftElement;
	this.annotation = annotation;
	this.rightElement = rightElement;
	dirtyListener.setDirty();
    }

    /**
     * Get the associator of this event.
     * 
     * @return the associator
     * 
     */
    public Associator<L, A, R> getAssociator() {
	return (Associator<L, A, R>) getSource();
    }

    /**
     * Get the left element of this event.
     * 
     * @return the left element
     * 
     */
    public L getLeftElement() {
	return leftElement;
    }

    /**
     * Get the annotation of this event.
     * 
     * @return the annotation
     * 
     */
    public A getAnnotation() {
	return annotation;
    }

    /**
     * Get the right element of this event.
     * 
     * @return the right element
     * 
     */
    public R getRightElement() {
	return rightElement;
    }

}
